#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

vector<int>path;
vector<vector<int> >result;

void backtracking(vector<int>candidates,vector<int>used,int target,int sum,int startindex){
	if(sum==target){
		result.push_back(path);
	}
	for(int i=startindex;i<candidates.size();i++){
		if(i>0&&candidates[i]==candidates[i-1]&&used[i-1]==0){
		    continue;
	    } 
		path.push_back(candidates[i]);
		sum+=candidates[i];
		used[i]=1;
		backtracking(candidates,used,target,sum,i+1);
		used[i]=0;
		sum-=candidates[i];
		path.pop_back();
	}
}
int main()
{
	vector<int>candidates={10,1,2,7,6,1,5};
	int target;
	cin>>target;
	sort(candidates.begin(),candidates.end());
	vector<int>used;
	for(int i=0;i<candidates.size();i++){
		used.push_back(0);
	}
	backtracking(candidates,used,target,0,0);
	for(vector<vector<int> >::iterator it=result.begin();it!=result.end();it++){
		for(vector<int>::iterator iit=(*it).begin();iit!=(*it).end();iit++){
			cout<<(*iit)<<' ';
		}
		cout<<endl;
	}
	return 0;
 } 
